import 'package:flutter/material.dart';
import 'package:jieqifang/global.dart';
import 'package:jieqifang/pages/detail.dart';

class Item extends StatefulWidget {
  Item({Key key, this.data, this.index}) : super(key: key);
  final data;
  final int index;

  @override
  _ItemState createState() => _ItemState();
}

class _ItemState extends State<Item> {
  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return InkWell(
      onTap: () {
        Navigator.push(
          context,
          MaterialPageRoute(
            builder: (context) => DetailPage(index: widget.index),
          ),
        );
      },
      child: Container(
        width: MediaQuery.of(context).size.width,
        height: 80,
        decoration: BoxDecoration(
          gradient: LinearGradient(
            begin: Alignment.centerLeft,
            end: Alignment.centerRight,
            colors: [
              widget.data['color'],
              Global.backgroundColor,
              Global.backgroundColor,
              Global.backgroundColor,
              Global.backgroundColor,
            ],
          ),
        ),
        child: Row(
          children: [
            Container(
              width: 50,
              height: 80,
              child: Row(
                children: [
                  SizedBox(width: 10),
                  Expanded(
                    child: Text(
                      widget.data['name'],
                      style: TextStyle(
                        color: Global.backgroundColor,
                        fontFamily: 'QiuHongKai',
                        fontSize: 27,
                      ),
                    ),
                  )
                ],
              ),
            ),
            SizedBox(width: 20),
            Expanded(
              child: Text(
                widget.data['intro'],
                style: TextStyle(
                  color: Global.fontColor,
                  fontFamily: 'QiuHongKai',
                  fontSize: 17,
                  fontWeight: FontWeight.w500,
                  height: 2,
                ),
              ),
            ),
            SizedBox(width: 10),
            Icon(
              Icons.arrow_forward_ios,
              size: 15,
              color: Global.fontColor,
            ),
            SizedBox(width: 10),
          ],
        ),
      ),
    );
  }
}
